#ifndef _SMART_DEVICE_MANAGER_HEAD_H
#define _SMART_DEVICE_MANAGER_HEAD_H
#include <istream>
#include <vector>
#include "smart-device-protocol.h"
#include "linux-uart.h"

class SmartDeviceManager
{
public:
	enum
	{
		SmatDeviceOpen  = 0x00,
		SmatDeviceClose = 0x01,
		SmatDeviceQuery = 0x02,
	};
	SmartDeviceManager(const string &uartDevice);
	bool sendPacket(const vector<uint8_t> &packet);
	bool recvPacket(vector<uint8_t> &packet);

	//--------------门锁打开-----------------
	bool openDoorlock(uint8_t deviceType, uint8_t deviceNumber);
	bool closeDoorlock(uint8_t deviceType, uint8_t deviceNumber);
	bool queryDoorlock(uint8_t deviceType, uint8_t deviceNumber, uint8_t &lockStatus);

	//--------------电器设备-----------------
	bool openElectrical(uint8_t deviceType, uint8_t deviceNumber);
	bool closeElectrical(uint8_t deviceType, uint8_t deviceNumber);
	bool queryElectrical(uint8_t deviceType, uint8_t deviceNumber, uint8_t &lockStatus);
	//--------------传感器--------------------
	bool querySensor(uint8_t deviceType, uint8_t deviceNumber, uint16_t &data);

	//--------------嗅探设备-----------------
	// 设备地址(4byte) + 设备类型(2byte) + 设备编号(1byte)
	bool sniffingDevice(uint8_t deviceType, uint8_t deviceNumber, vector<uint8_t> &info);

	bool communication(SmartDeviceProtocol &protocol, vector<uint8_t> &ackData);

private:
	LinuxUart linuxUart;
};

#endif